package com.android.mtchat;

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class MainActivityCreateAccount extends Activity{
	
	String[] item = {"saigon","vung tau","da lat","hue"}; 
	Spinner ThanhPho;
	Button btnok;
	Button back;
	EditText etusername;
	EditText etpassword1;
	EditText etpassword2;
	EditText etname;
	 private XMPPConnection connection;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_create_account);
		ThanhPho = (Spinner)findViewById(R.id.SpCounty);
		ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivityCreateAccount.this,android.R.layout.simple_spinner_item,item );
		adapter.setDropDownViewResource(android.R.layout.simple_list_item_activated_1);
		ThanhPho.setAdapter(adapter);
		btnok=(Button)findViewById(R.id.btnCreateAccount);
		back=(Button)findViewById(R.id.btnBack);
		etusername=(EditText)findViewById(R.id.editText1);
		etpassword1=(EditText)findViewById(R.id.edPassWord);
		etpassword2=(EditText)findViewById(R.id.edPassWord2);
		etname=(EditText)findViewById(R.id.editName);
		final XmppManager xmpp=new XmppManager("115.73.103.233",5222);
		try {
			xmpp.init();
		} catch (XMPPException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		btnok.setOnClickListener(new OnClickListener() {	
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String username=etusername.getText().toString();
				String password1=etpassword1.getText().toString();
				String password2=etpassword2.getText().toString();
				String name=etname.getText().toString();
				String []a={password1,password2};
//				String name=
				try {
					xmpp.createNewUser(username, password1);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		});
	}
}
